<template>
  <div class="add-program">
    <el-dialog v-model="modelShow" title="新增项目">
      <el-form :model="form">
        <el-form-item label="No" :label-width="100">
          <el-input v-model="form.no" autocomplete="off" />
        </el-form-item>
        <el-form-item label="项目名称" :label-width="100">
          <el-input v-model="form.name" autocomplete="off" />
        </el-form-item>
        <el-form-item label="负责人" :label-width="100">
          <el-input v-model="form.people" autocomplete="off" />
        </el-form-item>
        <el-form-item label="项目启动日期" :label-width="100">
          <el-date-picker v-model="form.date" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="date"
            placeholder="请选择启动时间" />
        </el-form-item>
        <el-form-item label="当前人数" :label-width="100">
          <el-input-number v-model="form.prople_num" :min="1" />
        </el-form-item>
        <el-form-item label="项目周期" :label-width="100">
          <el-input v-model="form.program_cycle" autocomplete="off" />
        </el-form-item>
        <el-form-item label="项目状态" :label-width="100">
          <el-input-number v-model="form.program_status" :min="0" :max="100" />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="modelShow = false">取消</el-button>
          <el-button type="primary" @click="submit">
            确定
          </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="addProgram">
import { ref, reactive, defineExpose, defineEmits } from 'vue'
import { random } from 'loadsh'

const emits = defineEmits(['onSubmit'])
const modelShow = ref(false)

const form = reactive({
  no: `1000${random(1000, 9999)}`,
  name: `1000${random(1000, 9999)}-项目`,
  people: '张学友',
  date: `2022-11-${random(10, 30)}`,
  prople_num: random(10, 99),
  program_cycle: random(1, 9),
  program_status: random(1, 100)
})

const submit = () => {
  emits('onSubmit', form)
  modelShow.value = false
}
defineExpose({
  modelShow
})

</script>

<style lang="less" scoped src="./add-program.less">

</style>
